﻿<%@ Page Title="Administrar Vehiculos" Language="C#" MasterPageFile="~/Site.master"
    AutoEventWireup="true" CodeFile="ABMVehiculoEmpresa.aspx.cs" Inherits="Empresa_ABMVehiculoEmpresa" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <style type="text/css">
        .tdField
        {
            width: 180px;
            float: left;
            height: 26px;
        }
        .tdValue
        {
            height: 26px;
        }
        .tdValue > select
        {
            margin-left: 0px;
            width: 150px;
        }
        .tdValue > input
        {
            margin-left: 0px;
        }
        .tdFiltroField
        {
            width: 50px;
            float: left;
        }
        .tdFiltroValue
        {
            width: 120px;
            float: left;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
   
    <div class="ui-widget ui-widget-content ui-corner-all" style="margin-top: 5px; margin-bottom: 5px;
        padding: 5px;height:25px;">
        <div class="tdFiltroValue">
            <strong>Filtros</strong>
        </div>
        <div class="tdFiltroField">
            Tipo:
        </div>
        <div class="tdFiltroValue">
            <asp:DropDownList ID="cmbTipoFiltro" runat="server" AutoPostBack="True" OnSelectedIndexChanged="cmbTipoFiltro_SelectedIndexChanged">
            </asp:DropDownList>
        </div>
        <div class="tdFiltroField">
            Activo:
        </div>
        <div class="tdFiltroValue">
            <asp:DropDownList ID="cmbActivoFiltro" runat="server" AutoPostBack="True" OnSelectedIndexChanged="cmbActivoFiltro_SelectedIndexChanged">
            </asp:DropDownList>
        </div>
    </div>
    <div class="buttoncontainer" style="clear: both">
        <asp:LinkButton ID="cmdNuevo" runat="server" OnClick="cmdNuevo_Click" CssClass="button">Nuevo Vehiculo</asp:LinkButton>
    </div>
    <br />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <div id="table_Filter">
                <input id="txtFiltro" type="text" style="border: solid 1px #cccccc; width: 100%;"
                    class="filter" />
                <asp:GridView ID="grd" runat="server" OnRowCommand="grd_RowCommand" AutoGenerateColumns="False"
                    Width="100%">
                    <Columns>
                        <asp:BoundField DataField="Flota" HeaderText="Flota">
                            <ItemStyle Width="140px" />
                            <HeaderStyle HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:BoundField DataField="TipoVehiculo" HeaderText="Tipo">
                            <ItemStyle Width="140px" />
                            <HeaderStyle HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Descripcion" HeaderText="Descripción">
                            <ItemStyle Width="200px" />
                            <HeaderStyle HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Patente" HeaderText="Patente">
                            <ItemStyle Width="70px" />
                            <HeaderStyle HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Chofer" HeaderText="Chofer">
                            <ItemStyle Width="180px" />
                            <HeaderStyle HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:BoundField DataField="VelocidadMaxima" HeaderText="Vel. Max.">
                            <ItemStyle Width="70px" HorizontalAlign="Right" />
                            <HeaderStyle HorizontalAlign="Right" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="Activo">
                            <HeaderStyle HorizontalAlign="Left" />
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lbl" Text='<%# Eval("Activo").ToString().ToLower()=="s"?"Si":"No" %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:ButtonField CommandName="modificar" Text="Modificar" ButtonType="Image" 
                            ImageUrl="~/Graphics/editar20.png" >
                        <ItemStyle Width="1px" />
                        </asp:ButtonField>
                    </Columns>
                </asp:GridView>
            </div>
            <div id="dialog" style="display: none" title="Vehiculos">
                <div id="c1" class="tdField">
                    Tipo:
                </div>
                <div id="v1" class="tdValue">
                    <asp:DropDownList ID="cmbTipo" runat="server">
                    </asp:DropDownList>
                </div>
                <div id="c2" class="tdField">
                    Descripción:
                </div>
                <div id="v2" class="tdValue">
                    <asp:TextBox ID="txtDescripcion" runat="server" MaxLength="80" Width="360px"></asp:TextBox>
                </div>
                <div id="c3" class="tdField">
                    Patente:
                </div>
                <div id="v3" class="tdValue">
                    <asp:TextBox ID="txtPatente" runat="server" MaxLength="7" Width="75px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvPatente" runat="server" ControlToValidate="txtPatente"
                        ErrorMessage="Ingrese una patente válida" ValidationGroup="abm" ForeColor="Red">*</asp:RequiredFieldValidator>
                </div>
                <div id="c4" class="tdField">
                    Chofer:
                </div>
                <div id="v4" class="tdValue">
                    <asp:DropDownList ID="cmbChofer" runat="server">
                    </asp:DropDownList>
                </div>
                <div id="c5" class="tdField">
                    Flota:
                </div>
                <div id="v5" class="tdValue">
                    <asp:DropDownList ID="cmbFlota" runat="server">
                    </asp:DropDownList>
                </div>
                <div id="c6" class="tdField">
                    Velocidad Max. Permitida:
                </div>
                <div id="v6" class="tdValue">
                    <asp:TextBox ID="txtVelocidad" runat="server" MaxLength="3" Width="38px"></asp:TextBox>
                    <asp:CompareValidator ID="cvVelocidad" runat="server" ControlToValidate="txtVelocidad"
                        ErrorMessage="Ingrese una velocidad válida" Operator="DataTypeCheck" Type="Integer"
                        ValidationGroup="abm" ForeColor="Red">Ingrese una velocidad válida</asp:CompareValidator>
                </div>
                <div id="c7" class="tdField">
                    Activo:
                </div>
                <div id="v7" class="tdValue">
                    <asp:CheckBox ID="chkActivo" runat="server" Text="Activo" />
                </div>
                <div id="c8" style="width: 320px; font-style:italic; float: left;">
                    * Datos requeridos
                </div>
                <div id="botones" style="text-align: right;">
                    <br />
                    <asp:LinkButton ID="cmdAceptar" runat="server" CssClass="button" OnClick="cmdAceptar_Click"
                        ValidationGroup="abm">Aceptar</asp:LinkButton>
                     <asp:LinkButton ID="cmdCancelar" runat="server" PostBackUrl="~/Empresa/ABMVehiculoEmpresa.aspx"
                            CssClass="button">Cancelar</asp:LinkButton>
                </div>
            </div>
             <input type="hidden" name="hidShowDialog" value="" id="hidShowDialog" runat="server" />
             <input type="hidden" name="title" id="hidTitle" value="" runat ="server" />
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="cmdNuevo" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="cmbActivoFiltro" EventName="SelectedIndexChanged" />
            <asp:AsyncPostBackTrigger ControlID="cmbTipoFiltro" EventName="SelectedIndexChanged" />
        </Triggers>
    </asp:UpdatePanel>
    <script>
        function ShowDialog(titulo) {
            $("#dialog").dialog({ modal: true, width: 600, resizable: false, title: titulo }).parent().appendTo(jQuery("form:first"));
        }
////      Ya no va mas porque ahira refresca la pagina
//        function HideDialog() {
//            $(".ui-dialog-titlebar-close").click();
//        }

        var prm = Sys.WebForms.PageRequestManager.getInstance();

        prm.add_endRequest(EndRequest);

        function EndRequest(sender, args) {
            var band = $("#<%=hidShowDialog.ClientID %>").val();
           
            if (band == "true") {
                ShowDialog($("#<%=hidTitle.ClientID %>").val());
            }

            $("#table_Filter").liveFilter();
        }

        $(document).ready(function () {

            $("#table_Filter").liveFilter();

        });


    </script>
</asp:Content>
